home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / wndwc20.zip / WNDWDEMO.C < prev    next >
Text File  |  1989-03-06  |  14KB  |  378 lines

  1. /*===========================================================================*\
  2. | WNDWDEMO.C - Multi-level window demo for WNDWC20         ver 2.0, 03-06-89  |
  3. |                                                                             |
  4. | This demo shows just a few features of multi-level windows, including high  |
  5. | speed screen design.                                                        |
  6. |   Copyright(c) 1989 by James H. LeMay,  All rights reserved.                |
  7. |   Conversion to Turbo C by Jordan Gallagher / Wisdom Research               |
  8. \*===========================================================================*/
  9.  
  10. #include <stdio.h>
  11. #include <conio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <process.h>
  15.  
  16. #include "qwikc20.h"
  17. #include "wndwc20.h"
  18.  
  19. #define FUNCKEY 0
  20. #define RETKEY 13
  21. #define ESCKEY 27
  22.  
  23. enum {
  24.     STEP0,
  25.     STEP1,
  26.     STEP2,
  27.     STEP3,
  28.     STEP4,
  29.     STEP5
  30. };
  31.  
  32. int step=STEP0;
  33. int i,j;
  34. char key;
  35. char tmp[10];
  36. char tmp2[10];
  37.  
  38. char stra[16][40]=
  39. { "WNDWC20 works with these ...",
  40.   "",
  41.   "COMPUTERS:           ADAPTERS:",
  42.   "──────────────────   ─────────",
  43.   "IBM PC               MDA",
  44.   "IBM XT               CGA",
  45.   "IBM AT               EGA",
  46.   "IBM PCjr             MCGA",
  47.   "IBM PC Convertible   VGA",
  48.   "IBM PS/2 Model 25    8514/A",
  49.   "IBM PS/2 Model 30    Hercules:",
  50.   "IBM PS/2 Model 50     HGC",
  51.   "IBM PS/2 Model 60     HGC Plus",
  52.   "IBM PS/2 Model 70     InColor",
  53.   "IBM PS/2 Model 80 ",
  54.   "IBM 3270 PC" };
  55. char strb[13][40]=
  56. { "If you have any questions or comments,",
  57.   "please write to or call:",
  58.   "",
  59.   "     Eagle Performance Software",
  60.   "     TC Products",
  61.   "     Attn: Jordan Gallagher",
  62.   "           (CIS 73557,2342)",
  63.   "     P.O. Box 292786",
  64.   "     Lewisville, TX  75029-2786",
  65.   "     (214) 539-7855",
  66.   "",
  67.   "Or call The Eagle BBS 24 hrs. a day at",
  68.   "(214) 539-9878, 1200/2400 N81" };
  69.  
  70.  
  71. /*=========================| displaybasescreen |============================*\
  72. Displays text on the base screen (WINDOW0).
  73. \*==========================================================================*/
  74. void displaybasescreen(void)
  75. {
  76.     /* -- Create initial screen -- */
  77.     wwritec( 2, "Multi-Level Virtual Windows" );
  78.     wwritec( 3, "Version 2.0 for" );
  79.     wwritec( 4, "Turbo C 2.0" );
  80.     tws.wndwattr = LIGHTGRAY_BG;
  81.     wwritec( 6, "For each of the following displays:" );
  82.     wwritec( 8, "1. Press RETURN to continue." );
  83.     wwritec( 9, "2. Press ESC to back up.    " );
  84.     tws.wsline = SINGLE_BORDER;
  85.     wlineh(12, 1, crt_cols );
  86.     wwritec( 16,"This is the base screen without windows.  Let's just see  ");
  87.     wwritec( 17,"how fast WNDWC can create complex screen designs.  As soon");
  88.     wwritec( 18,"as you press return, WNDWC will start creating a screen   ");
  89.     wwritec( 19,"from scratch.  Nothing has been done yet.  Then WNDWC will");
  90.     wwritec( 20,"display the resulting window on the screen.  Try to time  ");
  91.     wwritec( 21,"it, but don't blink!                                      ");
  92.     step=STEP0;
  93. }
  94.  
  95.  
  96. /*==============================| doassets |================================*\
  97. \*==========================================================================*/
  98. void doassets(void)
  99. {
  100.     setwindowmodes( SEETHRUMODE+RELMODE );
  101.     makewindow( 3, 1, 12, 39, GREEN_BG, SAMEATTR, NO_BORDER, AWINDOW );
  102.     tws.wndwattr = LIGHTGRAY_BG;
  103.     wclrline( 1 );
  104.     wwritec( 1,    "A S S E T S" );
  105.     weostorc( 3, 33 );
  106.     qfilleos( 12, 7, LIGHTGRAY_BG, ' ' );
  107.     tws.wndwattr = tws.origattr;
  108.     wwrite( 2, 2, "Current Assets:" );
  109.     wwrite( 3, 3, "Cash and Equivalents" );
  110.     wwrite( 4, 3, "Accounts Receivable:" );
  111.     wclreos( tws.wndwattr );
  112.     wwrite( 5, 4, "United States" );
  113.     wwrite( 6, 4, "Canada" );
  114.     wwrite( 7, 4, "Europe" );
  115.     wwrite( 8, 3, "Contracts in process" );
  116.     wwrite( 9, 3, "Inventories" );
  117.     wwrite(10, 3, "Prepaid expenses" );
  118.     wwrite(11, 2, "Total Current Assets" );
  119.     wwrite(12, 2, "Property and Equipment" );
  120.     wwrite(14, 2, "Total Assets:" );
  121. }
  122.  
  123.  
  124. /*============================| doassetnums |===============================*\
  125. \*==========================================================================*/
  126. void doassetnums(void)
  127. {
  128.     int cash = 128;
  129.     int us = 1757;
  130.     int canada = 1827;
  131.     int europe = 1426;
  132.     int contracts = 10802;
  133.     int inventory = 4872;
  134.     int prepaid = 443;
  135.     int property = 1140;
  136.     long totalca,totalassets;
  137.  
  138.     makewindow( 3, 33, 12, 7, LIGHTGRAY_BG, SAMEATTR, NO_BORDER, AWINDOW );
  139.     totalca = cash+us+canada+europe+contracts+inventory;
  140.     totalassets = totalca+prepaid;
  141.  
  142.     wwritec( 3,  (sprintf(tmp,"%5s",itoa( cash,        tmp2,10)),tmp) );
  143.     wwritec( 5,  (sprintf(tmp,"%5s",itoa( us,          tmp2,10)),tmp) );
  144.     wwritec( 6,  (sprintf(tmp,"%5s",itoa( canada,      tmp2,10)),tmp) );
  145.     wwritec( 7,  (sprintf(tmp,"%5s",itoa( europe,      tmp2,10)),tmp) );
  146.     wwritec( 8,  (sprintf(tmp,"%5s",itoa( contracts,   tmp2,10)),tmp) );
  147.     wwritec( 9,  (sprintf(tmp,"%5s",itoa( inventory,   tmp2,10)),tmp) );
  148.     wwritec( 10, (sprintf(tmp,"%5s",itoa( prepaid,     tmp2,10)),tmp) );
  149.     wwritec( 11, (sprintf(tmp,"%5s",ltoa( totalca,     tmp2,10)),tmp) );
  150.     wwritec( 12, (sprintf(tmp,"%5s",itoa( property,    tmp2,10)),tmp) );
  151.     wwritec( 14, (sprintf(tmp,"%5s",ltoa( totalassets, tmp2,10)),tmp) );
  152. }
  153.  
  154.  
  155. /*===========================| doliabilities |==============================*\
  156. \*==========================================================================*/
  157. void doliabilities(void)
  158. {
  159.     makewindow( 3, 41, 12, 38, GREEN_BG, SAMEATTR, NO_BORDER, AWINDOW );
  160.     weostorc( 3, 32 );
  161.     qfilleos( 12, 7, LIGHTGRAY_BG, ' ' );
  162.     tws.wndwattr = WHITE+RED_BG;
  163.     wclrline( 1 );
  164.     wwritec( 1, "L I A B I L I T I E S" );
  165.     tws.wndwattr = tws.origattr;
  166.     wwrite( 2, 2, "Current Liabilities:" );
  167.     wclreos( tws.wndwattr );
  168.     wwrite( 3, 3, "Commercial paper" );
  169.     wwrite( 4, 3, "Accounts payable" );
  170.     wwrite( 5, 3, "Accrued salaries" );
  171.     wwrite( 6, 3, "Deferred taxes" );
  172.     wwrite( 7, 2, "Total Current" );
  173.     wwrite( 8, 2, "Noncurrent Liabilities:" );
  174.     wclreos( tws.wndwattr );
  175.     wwrite( 9, 3,  "Long-term debt" );
  176.     wwrite(10, 3,  "Product liability" );
  177.     wwrite(11, 3,  "Deferred taxes" );
  178.     wwrite(12, 2, "Total Noncurrent" );
  179.     wwrite(14, 2, "Total Liabilities:" );
  180. }
  181.  
  182.  
  183. /*=============================| doliabnums |===============================*\
  184. \*==========================================================================*/
  185. void doliabnums(void)
  186. {
  187.     int paper = 3331;
  188.     int payable = 5776;
  189.     int salaries = 6430;
  190.     int taxes1 = 2344;
  191.     int longterm = 402;
  192.     int product = 1876;
  193.     int taxes2 = 1096;
  194.     long totalcl,totalnl, totalliabs;
  195.  
  196.     makewindow( 3, 72, 12, 7, LIGHTGRAY_BG, SAMEATTR, NO_BORDER, AWINDOW );
  197.     totalcl = paper+payable+salaries+taxes1;
  198.     totalnl = longterm+product+taxes2;
  199.     totalliabs = totalcl+totalnl;
  200.  
  201.     wwritec( 3,  (sprintf(tmp,"%5s",itoa( paper,      tmp2,10 )),tmp) );
  202.     wwritec( 4,  (sprintf(tmp,"%5s",itoa( payable,    tmp2,10 )),tmp) );
  203.     wwritec( 5,  (sprintf(tmp,"%5s",itoa( salaries,   tmp2,10 )),tmp) );
  204.     wwritec( 6,  (sprintf(tmp,"%5s",itoa( taxes1,     tmp2,10 )),tmp) );
  205.     wwritec( 7,  (sprintf(tmp,"%5s",ltoa( totalcl,    tmp2,10 )),tmp) );
  206.     wwritec( 9,  (sprintf(tmp,"%5s",itoa( longterm,   tmp2,10 )),tmp) );
  207.     wwritec( 10, (sprintf(tmp,"%5s",itoa( product,    tmp2,10 )),tmp) );
  208.     wwritec( 11, (sprintf(tmp,"%5s",itoa( taxes2,     tmp2,10 )),tmp) );
  209.     wwritec( 12, (sprintf(tmp,"%5s",ltoa( totalnl,    tmp2,10 )),tmp) );
  210.     wwritec( 14, (sprintf(tmp,"%5s",ltoa( totalliabs, tmp2,10 )),tmp) );
  211. }
  212.  
  213.  
  214. /*=============================| doauditor |================================*\
  215. \*==========================================================================*/
  216. void doauditor(void)
  217. {
  218.     makewindow( 18, 1, 6, 78, GREEN_BG, SAMEATTR, NO_BORDER, AWINDOW );
  219.     wwrite( 1, 2, "Auditor:" );
  220.     wwrite( 2, 2, "Business Address:" );
  221.     wwrite( 3, 2, "Mailing Address:" );
  222.     wwrite( 4, 2, "Contact:" );
  223.     wwrite( 5, 2, "Comments:" );
  224.     setwindowmodes( RELMODE );
  225.     makewindow( 18, 19, 6, 60, WHITE+BROWN_BG, SAMEATTR, NO_BORDER, AWINDOW );
  226.     wwrite( 1, 1, "Ferret Auditors of Texas, Inc." );
  227.     wwrite( 2, 1, "1234 Technical Avenue      " );
  228.     qwriteeos( GREEN_BG, " State: " );
  229.     qwriteeos( SAMEATTR, "Texas    " );
  230.     qwriteeos( GREEN_BG, " Zip: " );
  231.     qwriteeos( SAMEATTR, "76125-1200" );
  232.     wwrite( 3, 1, "P.O. Box 292786            " );
  233.     qwriteeos( GREEN_BG, " State: " );
  234.     qwriteeos( SAMEATTR, "Texas    " );
  235.     qwriteeos( GREEN_BG, " Zip: " );
  236.     qwriteeos( SAMEATTR, "76125-1281" );
  237.     wwrite( 4, 1, "John Q. Public, CPA        " );
  238.     qwriteeos( GREEN_BG, " Phone: " );
  239.     qwriteeos( SAMEATTR, "(817)-555-1212" );
  240.     wwrite( 5, 1, "Was this screen fast enough for you?" );
  241.     wwrite( 6, 1, "Press RETURN to continue or ESC to back up." );
  242. }
  243.  
  244.  
  245. /*============================| dopartitions |==============================*\
  246. \*==========================================================================*/
  247. void dopartitions(void)
  248. {
  249.     removewindow();       /* back to parent window. */
  250.  
  251.     wwritec( 1, "1989 CONSOLIDATED BALANCE (Dollars in thousands)" );
  252.     tws.wsline = SINGLE_BORDER;
  253.     wlineh(  2, 1, tws.wcols );
  254.     wlineh( 15, 1, tws.wcols );
  255.     wlinev(  3, 40, 14 );
  256.     wlinepart( 2, 40, BRDR_TT );
  257.     wlinepart( 15, 40, BRDR_CL );
  258.     wbrdrh( 17 );
  259. }
  260.  
  261.  
  262. /*========================| displayscreendesign |===========================*\
  263. \*==========================================================================*/
  264. void displayscreendesign(void)
  265. {
  266.     /* -- You can compare how much slower it would be if we didn't use -- */
  267.     /* -- HIDDENMODE.  Try without it and comment out writetohidden.   -- */
  268.     setwindowmodes( HIDDENMODE+CURSOROFFMODE );
  269.     makewindow( 1, 1, 25, 80, BLACK+GREEN_BG, WHITE+GREEN_BG,
  270.                 HDOUBLE_BORDER, WINDOW1 );
  271.     writetohidden( WINDOW1 );
  272.     titlewindow( TOP, LEFT, YELLOW+GREEN_BG, " High Speed Screen Design " );
  273.     doassets();
  274.     doassetnums();
  275.     doliabilities();
  276.     doliabnums();
  277.     doauditor();
  278.     dopartitions();
  279.     showwindow( WINDOW1 );
  280. }
  281.  
  282.  
  283. /*========================| displayequipmentlist |==========================*\
  284. \*==========================================================================*/
  285. void displayequipmentlist(void)
  286. {
  287.     /* -- Compatible computers and adapters for WNDWC20 -- */
  288.     setwindowmodes( ZOOMMODE );
  289.     makewindow( 4, 35, 18, 34, WHITE+BLUE_BG, LIGHTCYAN+BLUE_BG,
  290.                 HDOUBLE_BORDER, AWINDOW );
  291.     titlewindow( TOP, CENTER, SAMEATTR, " Software Compatibility " );
  292.     for(j=0; j<16; j++) wwrite( j+1, 2, stra[j] );
  293. }
  294.  
  295.  
  296. /*===========================| displayauthor |==============================*\
  297. \*==========================================================================*/
  298. void displayauthor(void)
  299. {
  300.     /* -- Author of WNDWC20 -- */
  301.     setwindowmodes( ZOOMMODE );
  302.     if(videomode != 7)
  303.         setwindowmodes( windowmodes+SHADOWRIGHT );
  304.     strcpy( (char *) brdr[USER_BORDER_2], "┌┴┐┤├└┬┘┼─┼┼│┼┼");
  305.     makewindow( 5, 20, 15, 42, WHITE+BROWN_BG, BROWN_BG, USER_BORDER_2,
  306.                 AWINDOW );
  307.     for(j=0; j<13; j++)
  308.         wwrite( j+1, 2, strb[j] );
  309.     titlewindow( BOTTOM, CENTER, SAMEATTR, " Press RETURN to exit " );
  310. }
  311.  
  312.  
  313. /*===============================| getkey |=================================*\
  314. \*==========================================================================*/
  315. void getkey(void)
  316. {
  317.     do {
  318.         key=getch();                      /* read keyboard input.      */
  319.         if(key==0)                        /* if first char was #00 ... */
  320.             key=getch();                  /* ... read second char.     */
  321.     } while( key!=RETKEY && key!=ESCKEY );
  322. }
  323.  
  324.  
  325. /*============================| findnextstep |==============================*\
  326. \*==========================================================================*/
  327. void findnextstep(void)
  328. {
  329.     switch(key) {
  330.         case ESCKEY: if(step > STEP0) {
  331.                          removewindow();
  332.                          step--;
  333.                      } break;
  334.  
  335.         case RETKEY: step++;
  336.     }
  337. }
  338.  
  339.  
  340. /*===========================| displaywindows |=============================*\
  341. \*==========================================================================*/
  342. void displaywindows(void)
  343. {
  344.     do {
  345.         getkey();
  346.         findnextstep();
  347.         if(key==RETKEY)
  348.             switch(step) {
  349.                 case STEP1:  displayscreendesign(); break;
  350.                 case STEP2:  displayequipmentlist(); break;
  351.                 case STEP3:  displayauthor();
  352.             }
  353.     } while(step != STEP4);
  354. }
  355.  
  356.  
  357. void main()
  358. {
  359.     int j;
  360.  
  361.     prefer_multitask=1;
  362.     qinit();
  363.     modcursor( cursor_off );
  364.     initwindow( BLUE+LIGHTGRAY_BG, 1, 1 );
  365.     displaybasescreen();
  366.     displaywindows();
  367.     /* -- Use the following statement to return to the original screen. -- */
  368.  
  369.     for(i=0,j=li; i<j; i++) removewindow();
  370.     wclrscr();
  371.     wwritec( 12, "Copyright (c) 1989  James H. LeMay" );
  372.     wwritec( 13, "Eagle Performance Software" );
  373.     modcursor( cursor_on );
  374.     gotorc( crt_rows, 1 );
  375.  
  376.     exit(0);
  377. }
  378.